﻿using System.Windows;
using Gao.Poker.Services;

namespace Gao.Poker.App
{
    /// <summary>
    /// Interaction logic for LoginWin.xaml
    /// </summary>
    public partial class LoginWin : Window
    {
        public LoginWin()
        {
            InitializeComponent();
#if DEBUG
            Username.Text = "admin";
            Password.Password = "admin";
#endif
            btnLogin.Click += Btn_Login_Click;
            btnClose.Click += Btn_Close_Click;
        }

        void Btn_Close_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

        void Btn_Login_Click(object sender, RoutedEventArgs e)
        {
            UserService user = new UserService();
            if(user.Login(Username.Text.Trim(),Password.Password) != null)
            {
                MainWin window = new MainWin();
                window.Show();
                Close();
            }
            else
            {
                MessageBox.Show("用户名密码错误");
            }
        }
    }
}
